
<%@ page import="cn.StudentDao" %>
<%@ page import="cn.Student" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.Page" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>学生列表</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
            $("#go").click(function () {
                $("form #pageNo").val($(this).prev().val());
                $("#studentForm").submit();
                //return false;
            });

            $(".pager a").click(function () {
                $("form #pageNo").val($(this).attr("data-no"));
                $("#studentForm").submit();
                return false;
            });
            $("#search").click(function () {
                $("form #pageNo").val(1);
                return true;
            });
        });
    </script>
</head>
<body>
<div>
    <form action="studentServlet" method="get" id="studentForm">
        <input type="hidden" name="pageNo" id="pageNo" value="1">
        姓名：<input type="search"  name="sname" value="${sname}"/>
        QQ：<input  type="search" name="qq" value="${qq}"/>
        手机号：<input  type="search" name="telephone" value="${telephone}"/>

        入学时间从<input type="date" name="startDate" value="<fmt:formatDate value='${startDate}' pattern='yyyy-MM-dd'/>"/>到
                  <input type="date" name="endDate" value="<fmt:formatDate value='${endDate}' pattern='yyyy-MM-dd'/>"/>
        <input type="submit" value="搜索" id="search"/>
        <a href="stuReg">添加新生</a>
    </form>
</div>
<table border="1" cellpadding="0" cellspacing="0">
    <tr>
        <th>学号</th><th>姓名</th><th>手机号</th><th>QQ</th><th>入学时间</th><th>操作</th>
    </tr>
<%

    Page<Student> p=(Page<Student>)request.getAttribute("stus");
    for(Student stu:p.getData()){

%>
    <tr>
        <td><%=stu.getStuno()%></td>
        <td><%=stu.getSname()%></td>
        <td><%=stu.getTelephone()%></td>
        <td><%=stu.getQq()%></td>
        <td><%=stu.getEnterdate()%></td>
        <td><a href="#">Xiugai</a><a href="#">delete</a>
            <a href="#">查看成绩</a>
        </td>
    </tr>
<%}%>

</table>
<p class="pager">
    <%--<a href="subjectServlet?pageNo=1&sname=<%=%>&qq=&telephone">首页</a>--%>
    <a href="subjectServlet?pageNo=1" data-no="1">首页</a>
    <%
        if(p.getPageNo()>1){
    %>
    <a href="studentServlet?pageNo=<%=p.getPageNo()-1%>" data-no="<%=p.getPageNo()-1%>">上一页</a>
    <%}%>
    <input type="number" min="1" value="<%=p.getPageNo()%>" max="<%=p.getTotalPages()%>" name="pageNo" width="40px" size="4"/><input type="button" id="go" value="go" style="width: 60px;"/>

    <%
        if(p.getPageNo()<p.getTotalPages()){
    %>

    <a href="studentServlet?pageNo=<%=p.getPageNo()+1%>"  data-no="<%=p.getPageNo()+1%>">下一页</a>
    <%}%>
    <a href="studentServlet?pageNo=<%=p.getTotalPages()%>" data-no="<%=p.getTotalPages()%>">最后一页</a>
</p>
</body>
</html>
